<?php
namespace EApiSwoole\Redis;
class Redis
{
      protected $pool;    
      protected $connection;

      public function __construct(Pool $pool)
      {
          $this->pool = $pool;
      }	  
	  public function __call($name, $arguments)
	      {
	          $this->connection = $this->pool->getConnection();
	          try {
	              $data = $this->connection->{$name}(...$arguments);
	          } catch (\RedisException $e) {
	              $this->pool->close(null);
	              throw $e;
	          }
	  
	          $this->pool->close($this->connection);
	  
	          return $data;
	      }
}